package com.dmgis.hndz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dmgis.entity.DmMapPoint;
import com.dmgis.hndz.pojo.*;
import com.dmgis.hndz.service.Qxca01aService;
import com.dmgis.hndz.mapper.Qxca01aMapper;
import com.dmgis.hndz.service.Zhaa01aService;
import com.dmgis.weblib.MapCommon;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
* @author Administrator
* @description 针对表【qxca01a(自动站信息表)】的数据库操作Service实现
* @createDate 2024-04-08 13:34:26
*/
@Service
public class Qxca01aServiceImpl extends ServiceImpl<Qxca01aMapper, Qxca01a>
    implements Qxca01aService{

    @Autowired
    private Zhaa01aService zhaa01aService;

    @Override
    public List<Point> queryBuffer(DmMapPoint[] arr,String type) {
        List<DmMapPoint> pointList= Arrays.asList(arr);
        if (type.equals("隐患点")){
            List<Point> list1=baseMapper.selectHidden(); //获取应急隐患点信息
            list1=list1.stream().filter(i->{
                return MapCommon.pointWithinPolygon(pointList,i.getLon(),i.getLat());
            }).collect(Collectors.toList());
            return list1;
        }
        if (type.equals("自动站")){
            List<Point> list2=baseMapper.selectTrue(); //获取实况雨量自动站信息
            list2=list2.stream().filter(i->{
                return MapCommon.pointWithinPolygon(pointList,i.getLon(),i.getLat());
            }).collect(Collectors.toList());
            return list2;
        }
        if (type.equals("城镇预报")){
            List<Point> list3=baseMapper.selectForecast(); //获取预报雨量发布站点信息
            list3=list3.stream().filter(i->{
                return MapCommon.pointWithinPolygon(pointList,i.getLon(),i.getLat());
            }).collect(Collectors.toList());
            return list3;
        }
        if(type.equals("普适化")){
            List<Point> list4=baseMapper.selectNormal(); //获取普适化监测点信息
            list4=list4.stream().filter(i->{
                return MapCommon.pointWithinPolygon(pointList,i.getLon(),i.getLat());
            }).collect(Collectors.toList());
            return list4;
        }
        return new ArrayList<>();
    }

}




